//
//  HIKBehaviour.m
//  StoryboardObject
//
//  Created by CaryaLiu on 2021/4/12.
//

#import "HIKBehaviour.h"
#import <objc/runtime.h>

@implementation HIKBehaviour

- (void)setOwner:(id)owner {
    if (_owner != owner) {
        [self hik_releaseLifeTimeFromObject:owner];
        _owner = owner;
        [self hik_bindLiftTimeToObject:owner];
    }
}

- (void)hik_bindLiftTimeToObject:(id)object {
    objc_setAssociatedObject(object, @selector(owner), self, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)hik_releaseLifeTimeFromObject:(id)object {
    objc_setAssociatedObject(object, @selector(owner), nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

@end
